/* -----------------------------------------------------------
 * Author: Marie Caswell
 * Testing Function: gainCard()
 * Description: Check for correct gainCard() behavior.  Uses
 * adventurer card draws and discards to verify correctness. 
 -----------------------------------------------------------*/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int main() {

	int seed = 1000;
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
    struct gameState G;

    memset(&G, 23, sizeof(struct gameState));   // clear the game state
    initializeGame(numPlayer, k, seed, &G); // initialize a new game

    printf("Initial hand count: %d\n", G.handCount[0]); //check player 1 hand count
    printf("Initial deck count: %d\n", G.deckCount[0]); //check player 1 deck count
    printf("Initial discard pile count: %d\n", G.discardCount[0]); //check player 1 discard pile size
    printf("Initial adventurer supply: %d\n", G.supplyCount[k[0]]); //check adventurer card supply

    gainCard(k[0], &G, 1, 0); //add adventurer card to player 1 deck

    printf("Post deck-draw deck count: %d\n", G.deckCount[0]); //check player 1 deck count
    printf("Post deck-draw hand count: %d\n", G.handCount[0]); //check player 1 hand count
    printf("Post deck-draw adventurer supply: %d\n", G.supplyCount[k[0]]); //check adventurer card supply

    assert(G.deckCount[0] == 6);
    assert(G.handCount[0] == 5);
    assert(G.supplyCount[k[0]] == 9);

    gainCard(k[0], &G, 0, 0); //add adventurer card to player 1 discard pile	

    printf("Post-discard, discard pile count: %d\n", G.discardCount[0]); //check player 1 discard pile size
    printf("Post discard adventurer supply: %d\n", G.supplyCount[k[0]]); //check adventurer card supply

    assert(G.discardCount[0] == 1);
    assert(G.supplyCount[k[0]] == 8);

    gainCard(k[0], &G, 2, 0); //add adventurer card to player 1 hand

    printf("Post hand-draw deck count: %d\n", G.deckCount[0]); //check player 1 deck count
    printf("Post hand-draw hand count: %d\n", G.handCount[0]); //check player 1 hand count
    printf("Post hand-draw adventurer supply: %d\n", G.supplyCount[k[0]]); 

    assert(G.deckCount[0] == 6);
    assert(G.handCount[0] == 6);
    assert(G.supplyCount[k[0]] == 7);

printf("\nTests passed.\n");
return 0;

} 
